#ifndef __RELAY_CTRL_H
#define __RELAY_CTRL_H
#include "includes.h"

#define MAX_RELAY_NUM 5
// typedef enum
//     RUN,

// }MCU_STATE_t;

typedef enum
{
    CHECK_DISASSEMBLE_STATE,
    CHECK_24V_STATE,
    CHECK_ESTOP_STATE,
    CHECK_POWER_BUTTON_STATE,
    IDLE_DELAY_STATE,
    IDLE_STATE
}PowerBoard_STATE_t;

typedef enum
{
    ON,
    OFF
}RELAY_CTRL_STATE;

typedef enum
{
    uC_JCQ,
    uC_ALL,
    uC_JRP,
    uC_AMP,
    FRD_CTL
}RELAY_GPIO_NAME;

typedef enum
{
    SYS_NORMAL_STATE,
    SYS_STANDBY_STATE
}SYS_STATE_t;

void relay_ctrl_poll(void);
uint8_t relay_ctrl(RELAY_GPIO_NAME WHICH_RELAY,RELAY_CTRL_STATE ON_OFF);
void all_relay_on(void);
void all_relay_off(void);
void relay_ctrl_gpio_init(void);

void record_broken_event(uint8_t value);
uint8_t read_broken_event(void);
void init_broken_event(void);
void test_readwrite_backup_register(void);

void stby_relay_off(void);
static void estop_relay_off(void);

void relay_ctrl_process(void);

extern uint16_t relay_ctrl_poll_time_count;

extern uint8_t abnormal_flag;
extern bool open_close_flag;
extern bool estop_flag;
extern bool is_motion_part_safe;
extern SYS_STATE_t sys_state;
#endif
